package com.skstudio.reportview;

import com.skstudio.report.ReportMem;
import com.skstudio.report.SpyData;

public class ReporterMem extends ReportViewController {

    ReportMem mMem = null;

    @Override
    public void setSpyData(SpyData ref) {
        super.setSpyData(ref);
        mMem = ref.getReportMem();
    }

    @Override
    public int getReportRows() {
        return 1;
    }

    @Override
    public int getReportColumns() {
        return mMem.mDataList.size();
    }

    @Override
    public int getEntry(int row, int col) {
        if (row == 0 && mMem.mDataList.size() > col) {
            return (int) mMem.mDataList.get(col).getUsed();
        }
        return 0;
    }

    @Override
    public String getReportDescription() {
        return "Memory Usage";
    }

    @Override
    public String getEntryName(int row) {
        switch (row) {
            case 0:
                return "The amount of virtual memory used";
        }
        return null;
    }

    @Override
    public String getEntryHint(int col) {
        if (mMem.mDataList.size() > col) {
            ReportMem.DataMem dc = mMem.mDataList.get(col);
            String hint = String.format("Total %dk, Used %dk, Free %dk", dc.mTotal, dc.mUsed, dc.mFree);
            return hint;
        }
        return null;
    }
}
